package hu.village.mapper;

import hu.village.pojo.Account;
import hu.village.pojo.Admin;
import hu.village.pojo.Village;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AdminMapper {
    //管理员登录
    @Select("select * from admin where admin_name = #{adminName} and password = #{password}")
    Admin selectAdmin(String adminName, String password);

    //查看绑定财务委员申请
    @Select("select * from village where state = 1")
    List<Village> selectBinding();

    //处理绑定财务委员的申请
    @Update("update village set state = #{state},committee = #{committee} where village_name = #{villageName}")
    void updateAccountStateByVillageName(Village village);

    @Select("select * from account where state = 1")
    List<Account> selectCheckingAccount();

    @Update("update account set state = #{state} where id = #{id}")
    void updateAccountStateById(Account account);

    @Select("select * from account where report_man IS NOT NULL")
    List<Account> selectReportAccount();

    @Update("update account set reported = #{reported},report_man = #{reportMan} where id = #{id}")
    void updateAccountStateByReportMan(Account account);

    //设置30天过后的账目过期
    @Update("update account set visible = 0 where id = #{id}")
    void setAccountVisible(Integer id);
}
